import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import eslintPlugin from 'vite-plugin-eslint'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'

export default defineConfig(() => {
	return {
		plugins: [
			vue(),
			VueSetupExtend(),
			eslintPlugin({
				include: ['src/**/*.ts', 'src/**/*.vue', 'src/*.ts', 'src/*.vue']
			})
		],
		server: {
			port: 8686,
			host: true,
			proxy: {
				'^/api': {
					// secure: false,
					// target: 'http://localhost:8010',
					target: 'https://cms.coderwyf.com',
					changeOrigin: true,
					rewrite: (path) => path.replace(/^\/api/, '')
				}
			}
		},
		resolve: {
			alias: {
				'@': '/src'
			}
		},
		build: {
			rollupOptions: {
				output: {
					entryFileNames: 'js/[name].[hash].js',
					chunkFileNames: 'js/[name].[hash].js',
					assetFileNames: '[ext]/[name].[hash].[ext]'
				}
			}
		}
	}
})
